package cn.panda.edu.service.impl;

import cn.panda.edu.dao.StudentMapper;
import cn.panda.edu.model.Student;
import cn.panda.edu.service.StudentService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
public class StudentServiceImpl implements StudentService {

	@Autowired
	private StudentMapper studentMapper ;


	@Override
	public Student selectWithExamByPrimaryKey(Integer studentId, Integer state) {
		// TODO Auto-generated method stub
		return studentMapper.selectWithExamByPrimaryKey(studentId,state);
	}

	@Override
	public int deleteByPrimaryKey(Integer studentId) {
		// TODO Auto-generated method stub
		return studentMapper.deleteByPrimaryKey(studentId);
	}

	@Override
	public int insert(Student record) {
		// TODO Auto-generated method stub
		return studentMapper.insert(record);
	}

	@Override
	public int insertSelective(Student record) {
		// TODO Auto-generated method stub
		return studentMapper.insertSelective(record);
	}

	@Override
	public Student selectByPrimaryKey(Integer studentId) {
		// TODO Auto-generated method stub
		return studentMapper.selectByPrimaryKey(studentId);
	}

	@Override
	public int updateByPrimaryKeySelective(Student record) {
		// TODO Auto-generated method stub
		return studentMapper.updateByPrimaryKeySelective(record);
	}

	@Override
	public int updateByPrimaryKey(Student record) {
		// TODO Auto-generated method stub
		return studentMapper.updateByPrimaryKey(record);
	}
	
	@Override
	public PageInfo<Student> selectByPageAndSelective(Student student, int pageIndex, int pageSize) {
		// TODO Auto-generated method stub
		Map<String, Object> map = new HashMap<>();
		PageHelper.startPage(pageIndex, pageSize);
		List<Student> sList = studentMapper.selectByNameAndId(student);
		PageInfo<Student> pageInfo = new PageInfo<>(sList);
		return pageInfo;
	}

	@Override
	public Student selectByNameAndPwd(String nameString, String pwd) {
		return studentMapper.selectByNameAndPwd(nameString , pwd) ;
	}
	
	

}
